﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.MiniQuest {
    import flash.events.*;
    import Mechanics.GameMechanicInterfaces.*;
    import Mechanics.*;
    import Classes.*;
    import Display.*;
    import Mechanics.GameEventMechanics.*;
    import Modules.zoo.*;

    public class ZooDonationMQ extends MiniQuest {

        public static const QUEST_NAME:String = "zooDonationMQ";

        public function ZooDonationMQ(){
            super(QUEST_NAME);
        }
        public function get isQuestNeeded():Boolean{
            if (this.getFirstEnclosureWithDonations() != null){
                return (true);
            };
            return (false);
        }
        override protected function onIconClicked(_arg1:MouseEvent):void{
            var _local3:IGameMechanic;
            super.onIconClicked(_arg1);
            var _local2:ZooEnclosure = this.getFirstEnclosureWithDonations();
            if (_local2){
                _local3 = MechanicManager.getInstance().getMechanicInstance(_local2, ZooManager.MECHANIC_REWARDS_DIALOG, MechanicManager.PLAY);
                if (((_local3) && ((_local3 is FriendRewardsDialogMechanic)))){
                    UI.displayPopup((_local3 as FriendRewardsDialogMechanic).instantiateDialog());
                };
                _local3 = MechanicManager.getInstance().getMechanicInstance(_local2, ZooManager.MECHANIC_DIALOG_GENERATOR, MechanicManager.PLAY);
                if (((_local3) && ((_local3 is DialogGenerationMechanic)))){
                    UI.displayPopup((_local3 as DialogGenerationMechanic).instantiateDialog());
                };
            };
            m_recurrenceTime = 0;
        }
        private function getFirstEnclosureWithDonations():ZooEnclosure{
            var _local2:ZooEnclosure;
            var _local3:Object;
            var _local4:Number;
            var _local5:String;
            var _local1:Array = Global.world.getObjectsByTypes([WorldObjectTypes.ZOO_ENCLOSURE]);
            for each (_local2 in _local1) {
                _local3 = _local2.getDataForMechanic("giftSenders");
                if (_local3){
                    _local4 = 0;
                    for (_local5 in _local3) {
                        _local4++;
                    };
                    if (_local4 > 0){
                        return (_local2);
                    };
                };
            };
            return (null);
        }

    }
}//package Classes.MiniQuest 
